{[{define "sys/dict_list/add.html"}]}
{[{template "sys/base/mark.html"}]}
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>新增页面</title>
    <link rel="stylesheet" href="/pear-admin-layui/component/pear/css/pear.css"/>
</head>
<body>
<form class="layui-form" action="">
    <input name="typeCode" type="hidden" value="{[{.typeCode}]}">
    <div class="mainBox">
        <div class="main-container">
            <div class="layui-form-item">
                <label class="layui-form-label">dataLabel</label>
                <div class="layui-input-block">
                    <input type="text" name="dataLabel" autocomplete="off" placeholder="typeName"
                           lay-verType="tips" lay-verify="required" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">dataValue</label>
                <div class="layui-input-block">
                    <input type="text" name="dataValue" autocomplete="off" placeholder="typeCode"
                           lay-verType="tips" lay-verify="required" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">isDefault</label>
                <div class="layui-input-block">
                    <input type="checkbox" name="isDefault" lay-skin="switch">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">enable</label>
                <div class="layui-input-block">
                    <input type="checkbox" name="enable" lay-skin="switch">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">remark</label>
                <div class="layui-input-block">
                    <textarea name="remark" placeholder="请输入内容" class="layui-textarea"></textarea>
                </div>
            </div>
        </div>
    </div>
    <div class="bottom">
        <div class="button-container">
            <button type="submit" class="pear-btn pear-btn-primary pear-btn-sm" lay-submit=""
                    lay-filter="save">
                <i class="layui-icon layui-icon-ok"></i>
                提交
            </button>
            <button type="reset" class="pear-btn pear-btn-sm">
                <i class="layui-icon layui-icon-refresh"></i>
                重置
            </button>
        </div>
    </div>
</form>
<script src="/pear-admin-layui/component/layui/layui.js"></script>
<script src="/pear-admin-layui/component/pear/pear.js"></script>
<script>
    layui.use(['form', 'jquery', 'loading', 'layer'], function () {
        let form = layui.form;
        let $ = layui.jquery;
        let loading = layui.loading;
        let layer = layui.layer;

        form.on('submit(save)', function (data) {
            console.log(data);
            if (data.field.enable) {
                data.field.enable = true;
            }
            if (data.field.isDefault) {
                data.field.isDefault = true;
            }
            loading.Load(1, "loading data ...");
            $.post('/sys/dict_list/save', data.field, function (r) {
                loading.loadRemove(1000);
                if (r.code === 200) {
                    layer.msg(r.msg, {icon: 1, time: 1000}, function () {
                        parent.layer.close(parent.layer.getFrameIndex(window.name));
                        parent.layui.table.reload("dict-data-table");
                    });
                } else {
                    layer.msg(r.msg, {icon: 2, time: 1000});
                }
            });
            return false;
        });
    })
</script>
</body>
</html>
{[{end}]}
